// 本文件为title组件相关API

import axios from "@/js/my_axios"

//获取测试详情
function get_test_info(page, page_size) {
    return axios({
        method: 'get',
        url: 'version_manage/',
        params: {
            'page': page,
            'page_size': page_size,
        },
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

// 删除
function delete_test_info(val) {
    var status = false
    var val_list = []
    if (Array.isArray(val)) {
        val_list = JSON.parse(JSON.stringify(val))
        status = true
    }
    return axios({
        method: 'delete',
        url: 'version_manage/',
        data: {
            info: status ? val_list : val,
        },
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

// 过滤查询
function filter_query(page, page_size, filter) {
    return axios({
        method: 'get',
        url: 'version_manage/',
        params: {
            'page': page,
            'page_size': page_size,
            'time_filter': filter ? filter : '',
        },
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}
// 创建版本
function create_version(val) {
    return axios({
        method: 'post',
        url: 'version_manage/',
        data: val,
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}
// 添加安装包版本
function create_package(val) {
    return axios({
        method: 'post',
        url: 'pack_manage/',
        data: val,
    }).then((response) => {
        return response
    }).catch((error) => {
        console.log(error);
    });
}

export {
    get_test_info,
    delete_test_info,
    filter_query,
    create_version,
    create_package,
}